package com.example.testapp.activity.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.testapp.R;
import com.example.testapp.activity.activity.study.NewsActivity;
import com.example.testapp.activity.activity.study.WeaterActivity;

/**
 * Created by l on 2016/7/2.
 */
public class LearnFragment extends Fragment {

    private static final String ARG_PARAM1 = "param1";
    private String mParam1;

    public LearnFragment(){

    }

    public LearnFragment newInstance(String param) {
        LearnFragment fragment = new LearnFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //if(getArguments() != null){
           // mParam1 = getArguments().getString(ARG_PARAM1);
       // }
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_study, container, false);
        initView(view);
        return view;
    }

    private void initView(View view) {
        view.findViewById(R.id.weaterLayout).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), WeaterActivity.class));
            }
        });

        view.findViewById(R.id.newsLayout).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(getActivity(), NewsActivity.class));
            }
        });
    }
}
